﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;

namespace CTM.Web.Models.Input
{
    public class Org
    {
        #region Properties

        [Key]
        public Guid Id { get; set; }

        public Nullable<System.Guid> ParentId { get; set; }

        //[Required]
        //public string Code { get; set; }

        [Required]
        public string Name { get; set; }

        public string Description { get; set; }

        public string Path { get; set; }

        public bool IsDeleted { get; set; }

        public DateTime CreatedOn { get; set; }

        [StringLength(128)]
        public string CreatedBy { get; set; }

        public DateTime? ModifiedOn { get; set; }

        [StringLength(128)]
        public string ModifiedBy { get; set; }

        public DateTime? TransferredOn { get; set; }

        #endregion

        #region Relationship
        public virtual OrgType Type { get; set; }
        public virtual ApplicationUser Manager { get; set; }
        public virtual ICollection<ApplicationUser> Employees { get; set; }
        public virtual Org Parent { get; set; }
        [InverseProperty("Parent")]
        public virtual ICollection<Org> Children { get; set; }
        #endregion

        public Org()
        {
            IsDeleted = false;
            CreatedOn = DateTime.UtcNow;
            //ModifiedOn = DateTime.UtcNow;
            Employees = new HashSet<ApplicationUser>();
            Children = new HashSet<Org>();
        }
    }
}